import { CEllipsisText } from '@/components/CTable/CTable'
import ISocketPageVO from '@/model/vo/socket/ISocketPageVO'
import { getNameByValueAndDictList, handlerRegion } from '@/util/CommonUtil'
import { IconRadio } from '@douyinfe/semi-icons'
import { OptionProps } from '@douyinfe/semi-ui/lib/es/select'

export default (dictList: OptionProps[]) => [
  { title: 'socketId', dataIndex: 'id' },
  { title: '用户名', dataIndex: 'userName' },
  { title: 'ip', dataIndex: 'ip' },
  {
    title: 'ip区域',
    dataIndex: 'region',
    render: (text: any, record: ISocketPageVO, index: number) => {
      return (
        <CEllipsisText text={handlerRegion(record.region!)}></CEllipsisText>
      )
    },
  },
  { title: '浏览器', dataIndex: 'browser' },
  { title: '操作系统', dataIndex: 'os' },
  {
    title: '移动端网页',
    width: '110px',
    dataIndex: 'mobileFlag',
    render: (text: any, record: ISocketPageVO, index: number) => {
      return record.mobileFlag ? '是' : '否'
    },
  },
  {
    title: '状态',
    dataIndex: 'type',
    width: '70px',
    render: (text: any, record: ISocketPageVO, index: number) => {
      return (
        <IconRadio
          title={record.type === 1 ? '用户在线中' : '用户隐身中'}
          className={record.type === 1 ? 'green' : 'warning'}
        />
      )
    },
  },
  { title: '服务器', dataIndex: 'server' },
  {
    title: '类别',
    dataIndex: 'category',
    render: (text: any, record: ISocketPageVO, index: number) => {
      return getNameByValueAndDictList(dictList, record.category!)
    },
  },
  { title: '连接时间', dataIndex: 'createTime', sorter: true, width: '170px' },
]
